import { RouteLocationNormalized, createRouter, createWebHistory, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css'

import { appRoutes } from './routes'
// import { REDIRECT_MAIN, NOT_FOUND_ROUTE } from './routes/base';
import { REDIRECT_MAIN } from './routes/base'
import createRouteGuard from './guard'
NProgress.configure({ showSpinner: false }) // NProgress Configuration
const router = createRouter({
  history: createWebHashHistory('/web-admin'),
  routes: [
    {
      path: '/',
      redirect: 'login',
    },
    {
      path: '/home',
      name: 'home',
      component: () => import('@/views/home.vue'),
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/login/index.vue'),
      meta: {
        requiresAuth: false,
      },
    },
    ...appRoutes,
    REDIRECT_MAIN,

    // NOT_FOUND_ROUTE,
  ],
  scrollBehavior() {
    return { top: 0 }
  },
})

createRouteGuard(router)

export default router
